package com.mywork.activity;

import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.ciko.code.base.BaseActicity;
import com.ciko.code.bean.WorkMeetingListBean;
import com.ciko.code.http.BaseResponse;
import com.ciko.code.http.HttpClient;
import com.ciko.code.http.Req.GetWorkMeetingDetailReq;
import com.ciko.code.utils.DateUtil;
import com.ciko.code.utils.NetWorkUtils;
import com.ciko.code.utils.Util;
import com.mywork.R;


/**
 * Created by 12154 on 2015/11/5.
 */
public class WorkMeetingDetailActivity
        extends
        BaseActicity
{
	private int					meetingId = -1;
	private WorkMeetingListBean	bean;
	private TextView			tvTime, tvAddress, tvTopic, tvContent, tvPerson, tvClient;
	private LinearLayout		llParent, llClient, llContent;
	private View				viewClient, viewContent;
								
	@Override
	protected void initTopBar() {
		setTitle("会议详情");
		enableNavLeftImg();
	}
	
	@Override
	protected void initLayout() {
		setContentView(R.layout.activity_work_meeting_detail);
	}
	
	@Override
	protected void initView() {
		tvClient = findViewByID(R.id.tv_client);
		tvPerson = findViewByID(R.id.tv_person);
		tvTopic = findViewByID(R.id.tv_topic);
		tvTime = findViewByID(R.id.tv_time);
		tvAddress = findViewByID(R.id.tv_address);
		tvContent = findViewByID(R.id.tv_content);
		llParent = findViewByID(R.id.ll);
		llParent.setVisibility(View.GONE);
		llClient = findViewByID(R.id.ll_client);
		llContent = findViewByID(R.id.ll_content);
		viewClient = findViewByID(R.id.view_client);
		viewContent = findViewByID(R.id.view_content);
	}
	
	@Override
	protected void initAdapter() {
	
	}
	
	@Override
	protected void initDates() {
		if (!getIntent().getExtras().containsKey("meetingId"))
		                                                       return;
		meetingId = getIntent().getIntExtra("meetingId", -1);
		HttpClient.getInstance(this).post(new GetWorkMeetingDetailReq(meetingId), this);
	}
	
	@Override
	protected void initListener() {
	
	}
	
	@Override
	public void onResponseSuccess(BaseResponse<?> response, String tag) {
		super.onResponseSuccess(response, tag);
		llParent.setVisibility(View.VISIBLE);
		bean = (WorkMeetingListBean) response.getReturnObject();
		if (bean.customer.equals(""))
		
		{
			llClient.setVisibility(View.GONE);
			viewClient.setVisibility(View.GONE);
		}
		if (bean.content.equals(""))
		{
			llContent.setVisibility(View.GONE);
			viewContent.setVisibility(View.GONE);
		}
		tvContent.setText(bean.content);
		String strTime = DateUtil.longToDate(bean.meetingTime, 8);
//		tvTime.setText(strTime.substring(0, 4) + "年" + strTime.substring(5, 7) + "月" + strTime.substring(8, 10) + "日" + " " + strTime.substring(11, 13) + "点");
		tvTime.setText(strTime.substring(5, 7) + "月" + strTime.substring(8, 10) + "日" + "  " + strTime.substring(11, 13) + "点" + strTime.substring(14, 16) + "分");
		tvAddress.setText(bean.address);
		tvPerson.setText(bean.attendees);
		tvTopic.setText(bean.title);
		tvClient.setText(bean.customer);
	}
	
	@Override
	public void onResponseFail(String tag, int resultCode) {
		super.onResponseFail(tag, resultCode);
		if (NetWorkUtils.isConnected(this))
		                                    Util.showToast(this, "加载失败，请重试");
	}
}
